 <template>
  <div class="paperlibrary">
 		<div class="item_top_headder">
 			<el-row :gutter="24">
 				<el-col span="6" >
 					<el-col class="top_item" >
				  	<el-button @click="goAddPaper" type="primary" icon="fa fa-wpforms fa-lg" plain>生成试卷</el-button>
				  </el-col>
 				</el-col>
			  <el-col span="18">
			  	<el-row type="flex" class="row-bg" justify="end">
			  			<div class="search_advanced">
						  	<!--<el-popover
								  placement="bottom"
								  title="标题"
								  width="200"
								  trigger="click"
								  content="这是一段内容,这是一段内容,这是一段内容,这是一段内容。">
								  <div slot="reference">高级搜索	<i class="fa fa-chevron-down fa-lg"></i></div>
								</el-popover>-->
						  </div>
			  		
					  	<el-col class="top_item" :span="10" >
						  	<!--<el-input placeholder="请输入题目进行搜索" v-model="input5" class="input-with-select">
							    <el-button slot="append" icon="el-icon-search"></el-button>
							</el-input>-->
						  </el-col>
					</el-row>
 				</el-col>
			</el-row>
 		</div>
 		
 		<div class="question_list">
 			<el-table
	      :data="allPaperData"
	      style="width: 100%">
	      <el-table-column
	        prop="name"
	        label="试卷名"
	        width="180">
	      </el-table-column>
	      <el-table-column
	        prop="bundle"
	        label="分类"
	        width="180">
	      </el-table-column>
	      <el-table-column
	        prop="operator"
	        label="操作人">
	      </el-table-column>
	      <el-table-column
	        prop="address"
	        label="创建时间">
	         <template slot-scope="scope">
	         	<span>{{scope.row.create_time | getDateDeal}}</span>
	         </template>
	      </el-table-column>
	      <el-table-column
	        prop="sum_score"
	        label="总分值">
	      </el-table-column>
	      <el-table-column
	        prop="questions_count"
	        label="题目数量">
	      </el-table-column>
	      <el-table-column
	        prop="sum_score"
	        label="考试时长(分钟)">
	         <template slot-scope="scope">
	         	<span>{{scope.row.limit_time/60}}</span>
	         </template>
	      </el-table-column>
	       <el-table-column
	        prop="address"
	        label="操作">
	        <template slot-scope="scope">
	        <el-button
		        @click.native.prevent="editionPage(scope.row)"
		        type="text"
		        size="small">
		          	编辑
		        </el-button>
		        <!--<el-button type="text" style="color:red;" icon="el-icon-delete" ></el-button>-->
	      	</template>
	      </el-table-column>
	    </el-table>
 		</div>
 		<div class="footer">
 			<!--<el-pagination
			  background
			  layout="prev, pager, next"
			  :total="50">
			</el-pagination>-->
 		</div>
  </div>
</template>

<script>
    import { paperGetall,paperDetail,Login} from '@/assets/util/api.js'
  export default {
    data() {
      return {
      	access_token:"",
      	allPaperData: [],
      };
    },
     watch:{
    	'$route' (to, from) {
    		this.paperGetall(0);
    	},
    },
    mounted(){
      this.access_token = this.inStorage("get","access_token");
      this.paperGetall();
    },
    methods: {
     goAddPaper(){
     	this.RouterTo(this,"/itemBank/addPaper-step1",{step:1})
     },
     paperGetall(){
     	var _this = this;
     	let params = {
     		access_token:this.access_token
     	}
     	paperGetall(this,params).then((res)=>{
     		if(res.data.state){
     			_this.allPaperData = res.data.data;
     		}
     	}).catch((res)=>{
     		console.log(res);
     	})
     },
     editionPage(val){
     	let _this = this;
     	let params = {
     		access_token:this.access_token,
     		paper_no:val.paper_no
     	}
     	paperDetail(this,params).then((res)=>{
     		if(res.data.state){
     			_this.inStorage("set","pageEditor",res.data.data);
     			_this.RouterTo(_this,"/itemBank/addPaper-step2",{state:'edition'})
     		}
     	}).catch((res)=>{
     		console.log(res)
     	})
     }
    }
  }
 
</script>
<style lang="scss" scoped>
	.itembank{
		position: relative;
	}
  .top_item{
  	margin-bottom: 10px;
  	margin-right: 20px;
  	padding-bottom:40px;
  	box-sizing: border-box;
  }
  .search_advanced{
  	margin-top: 10px;
  	margin-right: 20px;
  	color: #1A8CFE;
  	cursor: pointer;
  	i{
  		margin-left: 3px;
  		transform: translateY(-30%);
  	}
  }
  .item_top_headder{
  	box-shadow: 0 1px 2px -2px #999;
  }
  .question_list{
  	margin-top: 2px;
  	width: 100%;
  }
  .footer{
  	width: 100%;
  	float: right;
  	text-align: right;
  	margin-top: 30px;
  	margin-right: 20px;
  }
</style>